package cn.zyq.ykb.system.enums.core;

import cn.zyq.ykb.system.exception.BusinessException;

public enum AdminUserTypeEnum {
    XTYH("系统用户", "00"),
    FWSYH("服务商用户", "01"),
    ;
    private final String key;
    private final String value;

    AdminUserTypeEnum(String key, String value) {
        this.key = key;
        this.value = value;
    }


    public static String getKeyByValue(String value) {
        for (AdminUserTypeEnum item : AdminUserTypeEnum.values()) {
            if (item.value.equals(value)) return item.key;
        }
        throw new BusinessException(ResponseCodeEnum.ERROR, "无效的value值");
    }

    public static String getValueByKey(String key) {
        for (AdminUserTypeEnum item : AdminUserTypeEnum.values()) {
            if (item.key.equals(key)) return item.getValue().toString();
        }
        throw new BusinessException(ResponseCodeEnum.ERROR, "无效的key值");
    }


    public String getValue() {
        return value;
    }

}
